package com.awn.weidian.demo.controller;


import com.awn.weidian.demo.mapper.IAddress;
import com.awn.weidian.demo.pojo.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/api/")
public class AddressController {

    @Autowired
    IAddress pm;

    @GetMapping("/showdz")
    public List<Address> showAll(){
        return pm.showAll();
    }


	/*
	 *模糊查询
	 * @return
	 */
//	@PutMapping("/findaid/{aa}")
//	public List<Address> findaid(@PathVariable String aa){
//		return pm.findaid(aa);
//	}

    /*
     * 地址数量
     * @return
     */
    @GetMapping("/showalldz")
    public int show(){
        return pm.show();

    }


//	@PostMapping("/fenye/{aa},{bb}")
//	public List<Map<String,Object>> show(@PathVariable int aa,int bb){
//		return pm.fenye(aa, bb);
//	}

    @PostMapping("/adddz")
    public int addAddress(@RequestBody Address address){
        return pm.Add(address);
    }

    @PostMapping("/updatedz")
    public int update(@RequestBody Address address){
        return pm.updateAll(address);

    }

    @DeleteMapping("/deldz/{aid}")
    public int Delect(@PathVariable int aid){
        return pm.Delect(aid);
    }



}
